#include "rs485.hpp"
#include <string.h>

using namespace device;

void rs485::DataSent(void) ///> 发送完毕进入接收状态
{
	gpio::Write(mGpioPin.GpioPort, mGpioPin.GpioPin, 0);
}

rs485::rs485(UartInstanceTPDF tInstance, uint8_t *ucSendBuff, uint8_t *ucRecBuff, uint16_t usBuffLen, gpio::GpioPinTPDF *tGpioPin)
	:uart(tInstance, ucSendBuff, ucRecBuff, usBuffLen)
{
	memcpy(&mGpioPin, tGpioPin, sizeof(gpio::GpioPinTPDF));
	gpio::Write(mGpioPin.GpioPort, mGpioPin.GpioPin, 0);
	mDmaSendHandle = 0;
}

bool rs485::Write(uint8_t *ucData, uint16_t usDataLen)
{
	bool ret = false;
	gpio::Write(mGpioPin.GpioPort, mGpioPin.GpioPin, 1);
	ret = uart::Write(ucData,usDataLen);
	return(ret);
}

bool rs485::Write(uint8_t *ucCmd, uint16_t usCmdLen, uint8_t *ucData, uint16_t usDataLen)
{
	return(false);
}
